<?php

function exportDataToXls($dataArr, $xlsName)
{
    require(APP_INC_PATH . 'execl/PHPExcel.php');
    $objExcel = new PHPExcel();
    $objWriter = new PHPExcel_Writer_Excel2007($objExcel); // 用于 2007 格式
    $objWriter->setOffice2003Compatibility(true);

    //*************************************
    //设置文档基本属性
    $objProps = $objExcel->getProperties();
    $objProps->setCreator("Zeal Li");
    $objProps->setLastModifiedBy("Zeal Li");
    $objProps->setTitle("Office XLS Test Document");
    $objProps->setSubject("Office XLS Test Document, Demo");
    $objProps->setDescription("Test document, generated by PHPExcel.");
    $objProps->setKeywords("office excel PHPExcel");
    $objProps->setCategory("Test");

    $objExcel->setActiveSheetIndex(0);
    $objActSheet = $objExcel->getActiveSheet();

    $objActSheet->setTitle('jl');

    $i = 1;
    $jmax = count($dataArr[1]);
    foreach ($dataArr as $v) {
        $j = 0;
        $iChar = 65;
        for ($j; $j < $jmax; $j++) {
            $objActSheet->setCellValue(chr($iChar) . $i, $dataArr[$i][$j]);
            $iChar++;
        }

        $i++;
    }
    $outputFileName = APP_EXPLORT_PATH . "xlsx/" . $xlsName;
    //到文件
    $objWriter->save($outputFileName);
    return true;
}
?>